import { createRouter, createWebHistory } from 'vue-router'
//import可以./ 从当前目录查找
import index from './views/index'
//import也可以使用@/从根查找
import goods from "@/views/goods"
import goods1 from "@/views/goods1";
import login from "@/views/login";

import user from "@/views/user";

// 创建路由实例对象
// createRouter:路由对象 创建一批控制器
const router = createRouter({
    history: createWebHistory(),//历史记录
    routes: [ //设置控制器
        { path: '/', name:'index',component:index },
        { path: '/goods', name:'goods',component:goods },
        { path: '/query/goods1', name:'goods1',component:goods1,props: route => ({ id:route.query.id,userName:route.query.userName,password:route.query.password }) },
        //rest请求需要配置路由 SpringMVC @PathVariable
        { path: '/rest/user/:id/:userName/:password', name:'user',component:user ,props:true},
        { path: '/login', name:'login',component:login },
    ],
})

//导出之前 其他地方import才可以使用
export default router
